﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace DomainExample.DomainModel.ContactModel
{
    /// <summary>
    /// Type Safe Enumeration for Contact Type
    /// </summary>
    public sealed class ContactType
    {
        private readonly string _name;

        private ContactType(string name)
        {
            _name = name;
        }

        public override string ToString()
        {
            return _name;
        }

        private const string ElectronicMailString = "Electronic Mail";
        private const string FacsimileString = "Facsimile";
        private const string InPersonString = "In Person";
        private const string InstantMessageString = "Instant Message";
        private const string TelephoneString = "Telephone";

        public static readonly ReadOnlyDictionary<string, ContactType> Types = new ReadOnlyDictionary<string, ContactType>(
            new Dictionary<string, ContactType>
        {
            { ElectronicMailString, new ContactType(ElectronicMailString) },
            { FacsimileString, new ContactType(FacsimileString) },
            { InPersonString, new ContactType(InPersonString) },
            { InstantMessageString, new ContactType(InstantMessageString) },
            { TelephoneString, new ContactType(TelephoneString) }
        });

        public static readonly ContactType ElectronicMail = Types[ElectronicMailString];
        public static readonly ContactType Facsimile = Types[FacsimileString];
        public static readonly ContactType InPerson = Types[InPersonString];
        public static readonly ContactType InstantMessage = Types[InstantMessageString];
        public static readonly ContactType Telephone = Types[TelephoneString];
    }
}
